package cn.edu.ctbu.lddweb.service.lmpl;

import cn.edu.ctbu.lddweb.mapper.LogonMapper;
import cn.edu.ctbu.lddweb.pojo.Logon;
import cn.edu.ctbu.lddweb.service.LogonService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 登录注册实现层
 */
@Service
public class LogonServicelmpl implements LogonService {

    @Autowired
    private LogonMapper logonMapper;

    @Override
    public List<Logon> selectList(Logon logon) {
        return logonMapper.selectList(logon);
    }

    @Override
    public Logon findID(@Param("id") int id) {
        return logonMapper.findID(id);
    }

    @Override
    public int insertLogon(Logon logon) {
        return logonMapper.insertLogon(logon);
    }

    /**
     * 检查是否唯一
     * @param logon
     * @return
     */
    @Override
    public Boolean checkSupplierUnique(Logon logon) {
        int id = logon.getId()==0?-1:logon.getId();
        Logon info = logonMapper.checkLogonUnique(logon);
        if(info!=null&&info.getId()!=id){
            return true;
        }
        return false;
    }

    @Override
    public int updateLogon(Logon logon) {
        return logonMapper.updateLogon(logon);
    }

    @Override
    public int deleteLogon(String id) {
        return logonMapper.deleteLogon(id);
    }

}
